from PyQt5.QtCore import QUrl, QObject, pyqtSlot
from PyQt5.QtGui import QGuiApplication
from PyQt5.QtQuick import QQuickView
import sys

class ShuoGGClass(QObject):

    @pyqtSlot(str)
    def printConsole(self, s):
        print(s)

if __name__ == '__main__':
    app = QGuiApplication(sys.argv)
    shuo = ShuoGGClass()
    view = QQuickView()
    ctx = view.rootContext()
    ctx.setContextProperty("shuo", shuo)
    view.engine().quit.connect(app.quit)
    view.setSource(QUrl("main.qml"))
    view.show()
    app.exec_()